<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') ?>
<title><?= $sf_response->getTitle() ?></title>

<?php use_stylesheet('/sf/sf_admin/css/main') ?>

<div id="sf_admin_container">

<h1>View <?php echo $bom->getWono() ?></h1>

<div id="sf_admin_content">

<fieldset id="sf_fieldset_none" class="">
<?php 
    if ($bom->getReviseId()) { ?>
        <input type="hidden" name="bom[revise_id]" id="bom_revise_id" value="<?php echo $bom->getReviseId() ?>" >
<?}        
?>
<div class="form-row">
  <?php echo label_for('bom[wono]', __($labels['bom{wono}']), 'class="required" ') ?>
  <div class="content<?php if ($sf_request->hasError('bom{wono}')): ?> form-error<?php endif; ?>">
  <?php if ($sf_request->hasError('bom{wono}')): ?>
    <?php echo form_error('bom{wono}', array('class' => 'form-error-msg')) ?>
  <?php endif; ?>

<!--Tien-->
  <?php $default = CommonValues::GenerateAutoNumber('BOM', $bom->getWono(), 'BOM')   ?>
   <input name="bom[wono]" id="bom_wono" value="<?php echo $default ?>"  type="hidden">
   <input name="bom_wono_show" id="bom_wono_show" value="<?php echo $default ?>" size="15" disabled="disabled" type="text">
   </div>
</div>

<div class="form-row">
  <?php echo label_for('bom[project_id]', __($labels['bom{project_id}']), 'class="required" ') ?>
  <div class="content<?php if ($sf_request->hasError('bom{project_id}')): ?> form-error<?php endif; ?>">
  <?php if ($sf_request->hasError('bom{project_id}')): ?>
    <?php echo form_error('bom{project_id}', array('class' => 'form-error-msg')) ?>
  <?php endif; ?>

  <?php $value = object_select_tag($bom, 'getProjectId', array (
  'related_class' => 'Project',
  'control_name' => 'bom[project_id]',
  'disabled'=>1,
)); 
    if ($bom->getReviseId())  {?>     
   <input name="bom[project_id]" id="bom_project_id" value="<?php echo$bom->getProjectId() ?>"  type="hidden">
   <input name="bom_wono_show" id="bom_wono_show" value="<?php echo $bom->getProject() ?>" size="30" disabled="disabled" type="text">
    <?}
    else 
        echo $value ? $value : '&nbsp;' ?>
    </div>
</div>




<div class="form-row">
  <?php echo label_for('bom[status]', __($labels['bom{status}']), '') ?>
  <div class="content<?php if ($sf_request->hasError('bom{status}')): ?> form-error<?php endif; ?>">
  <?php if ($sf_request->hasError('bom{status}')): ?>
    <?php echo form_error('bom{status}', array('class' => 'form-error-msg')) ?>
  <?php endif; ?>

  <?php 
        $status = $bom->getStatus()? $bom->getStatus(): CommonValues::$gBomStatus['key']['Initial'];
        $gStatus = CommonValues::$gBomStatus['value']; 
   ?>
    <input name="bom[status]" id="bom_status" value="<?php echo $status ?>"  type="hidden">
    <input name="bom_status_show" id="bom_status_show" value="<?php echo $gStatus[$status] ?>" size="10" disabled="disabled" type="text">
    </div>
</div>


<div class="form-row">
  <?php echo label_for('bom[notes]', __($labels['bom{notes}']), '') ?>
  <div class="content<?php if ($sf_request->hasError('bom{notes}')): ?> form-error<?php endif; ?>">
  <?php if ($sf_request->hasError('bom{notes}')): ?>
    <?php echo form_error('bom{notes}', array('class' => 'form-error-msg')) ?>
  <?php endif; ?>

  <?php $value = object_textarea_tag($bom, 'getNotes', array (
  'size' => '50x5',
  'control_name' => 'bom[notes]',
  'disabled'=>1,
)); echo $value ? $value : '&nbsp;' ?>
    </div>
</div>
    
</fieldset>

<!--Tien code here
get information for MR-->
<?php
    if ($bom->getComponentgroupId()){
        $componentGroupId = $bom->getComponentgroupId();
        
        $c = new Criteria();
        $c->add(ComponentsPeer::COMPONENTGROUP_ID , $componentGroupId);
        $c->addAscendingOrderByColumn(ComponentsPeer::ID);
        
        $compsList = ComponentsPeer::doSelect($c);
    }
?>


<table id ='added_components' "cellspacing="0" class="sf_admin_list">
<thead>
<tr>
      <th id="sf_admin_list_th_productcode" width="25%">Product Code
              </th>
      <th id="sf_admin_list_th_description" width="35%">Description
              </th>
      <th id="sf_admin_list_th_description" width="10%">Brand
              </th>       
      <th id="sf_admin_list_th_description" width="10%">Unit
              </th>
      
      <th id="sf_admin_list_th_description">Qty need</th>
      <th id="sf_admin_list_th_description">Supplied by Client</th>
</tr>
</thead>
<!--show component here-->
 <?php
 if (isset($compsList) && $compsList) {
    foreach ($compsList as $key=>$comps) {
        $comp= ComponentPeer::retrieveByPK($comps->getComponentId());?>
        <tr class="sf_admin_row_<?php echo $key%2?>">
            <input type="hidden" name="rowIds[]" id ="rowIds"  class = "ExistComponents" value="<? echo $comp->getId()?>"/>
            <td><?echo $comp->getProductcode()?></td>
            <td><?echo $comp->getDescription()?></td>
            <td><?echo $comp->getBrand()?></td>
            <td><?echo $comp->getComponentunit()?></td>
            <td><input type="text" name="qtys[]" id ="qtys" size="5" disabled value ="<?echo $comps->getQty1()?>"></td>
            <td><input type="checkbox" name="suppliedByClients[]" id ="suppliedByClients" disabled value="<?php echo $comps->getComponentId();?>"  <?php if (1 ==$comps->getQty2()) echo "checked"?>></td>
        </tr>
<?php } }?>
</table>

</div>

</div>
